package com.lims.algorithm.algset.graph.basic;

import java.io.IOException;
import java.util.Scanner;

/**
 * <功能简述> 图抽象类
 *
 * @author lims
 * @date 2020-08-19 10:54
 */
public abstract class GraphAbs<T> implements GraphBasic {
    /**
     * 顶点集合
     */
    protected T[] vertes;

    public GraphAbs() {
    }

    @Override
    public void DFS() {

    }

    @Override
    public void BFS() {

    }

    /**
     * 返回字符ch在顶点集中的位置
     *
     * @param ch
     * @return
     */
    abstract protected int getPosition(T ch);

    /**
     * 从键盘输入一个字符
     *
     * @return
     */
    protected char readChar() {
        char ch = '0';
        do {
            try {
                ch = (char) System.in.read();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } while (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')));
        return ch;
    }

    /**
     * 读取一个数字字符
     *
     * @return
     */
    protected int readInt() {
        Scanner scanner = new Scanner(System.in);
        return scanner.nextInt();
    }
}
